package com.hjxr.sysadmin.zsj.controller;

import java.util.Date;
import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.Introduction;
import com.hjxr.sysadmin.zsj.service.IIntroductionService;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;

/**
 * 襄阳概况图文Controller
 *
 * @author hjxr
 * @date 2021-03-17
 */
@Api("页面图片信息管理")
@RestController
@RequestMapping("/introduction")
public class IntroductionController extends BaseController
{
    @Autowired
    private IIntroductionService introductionService;

    /**
     * 查询襄阳概况图文列表
     */
    @ApiOperation("查询襄阳概况图文列表")
    //@PreAuthorize("@ss.hasPermi('system:introduction:list')")
    @GetMapping("/list")
    public TableDataInfo list(Introduction introduction)
    {
        startPage();
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        return getDataTable(list);
    }

    /**
     * 导出襄阳概况图文列表
     */
    @ApiOperation("导出襄阳概况图文列表")
    //@PreAuthorize("@ss.hasPermi('system:introduction:export')")
    @Log(title = "导出襄阳概况图文列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Introduction introduction)
    {
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        ExcelUtil<Introduction> util = new ExcelUtil<Introduction>(Introduction.class);
        return util.exportExcel(list, "introduction");
    }

    /**
     * 获取襄阳概况图文详细信息
     */
    @ApiOperation("获取襄阳概况图文详细信息")
    //@PreAuthorize("@ss.hasPermi('system:introduction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(introductionService.selectIntroductionById(id));
    }

    /**
     * 新增襄阳概况图文
     */
    @ApiOperation("新增襄阳概况图文")
    //@PreAuthorize("@ss.hasPermi('system:introduction:add')")
    @Log(title = "新增襄阳概况图文", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Introduction introduction)
    {
        introduction.setModifiedTime(new Date());
        return toAjax(introductionService.insertIntroduction(introduction));
    }

    /**
     * 修改襄阳概况图文
     */
    @ApiOperation("修改襄阳概况图文")
    //@PreAuthorize("@ss.hasPermi('system:introduction:edit')")
    @Log(title = "修改襄阳概况图文", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Introduction introduction)
    {
        introduction.setModifiedTime(new Date());
        return toAjax(introductionService.updateIntroduction(introduction));
    }

    /**
     * 删除襄阳概况图文
     */
    @ApiOperation("删除襄阳概况图文")
    //@PreAuthorize("@ss.hasPermi('system:introduction:remove')")
    @Log(title = "删除襄阳概况图文", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(introductionService.deleteIntroductionByIds(ids));
    }
}
